home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / irix / scripts / setup < prev    next >
Encoding:
Text File  |  1994-08-02  |  15.7 KB  |  489 lines

  1. #
  2. # $Id: setup,v 1.32 1994/02/22 21:53:27 carlson Exp carlson $
  3. #
  4. # setup        Called by .login and .cshrc
  5. #
  6. # Synopsis:
  7. #    if ( -e setup ) then
  8. #        set { login | cshrc }
  9. #        source setup
  10. #        unset { login | cshrc }
  11. #    endif
  12. #
  13. # Description:
  14. #    This file is to be used as an extension of the standard .cshrc
  15. #    and .login.  This way, if this file doesn't exist, the
  16. #    standard .cshrc and .login will still work in a basic manner.
  17. #
  18. #    By default, 'setup' does some basic initializing and setting
  19. #    of environment variables.  If the variable $login exists, does
  20. #    functions specific to .login.  If the variable $cshrc exists,
  21. #    does functions specific to .cshrc.
  22. #
  23. # Local csh Variables Defined:
  24. #    ansiterm    Set to one of the following:
  25. #            0    Not an interactive session
  26. #            1    Not an ANSI compatible terminal
  27. #            2    iris-ansi compatible terminal
  28. #            3    vt100 terminal
  29. #    home_host    Set to the machine which is my home.  If the
  30. #            machine which is being set up is NOT my home,
  31. #            then I don't do some things.
  32. #
  33. # Permanent csh Variables Defined:
  34. #    path        Set to the search path for executables.
  35. #    prompt        Set to a fancy prompt string.
  36. #    history        Set to the number of history lines to keep.
  37. #    cdpath        Set to the directories to search for
  38. #            subdirectories when doing a 'cd' command.
  39. #    filec        Set to allow file completion.
  40. #    fignore        Set to those extensions to ignore on file
  41. #            completion.
  42. #    ignoreeof    Set to ignore the ^D end of file to logout.
  43. #    notify        Set to notify when subprocesses complete.
  44. #
  45. # Environment Variables Defined:
  46. #    OS        Defined to the current version of the
  47. #            operating system and the alpha release version.
  48. #    DISPLAY        Set to the local display or, if running
  49. #            remotely, to the remote display.
  50. #    EMACSLOADPATH    Where EMACS looks for .el files.
  51. #    WINEDITOR    The editor Workspace defaults to.
  52. #    CONSOLE        TRUE if this is the console window.
  53. #            Otherwise, not set so we set it here to FALSE.
  54. #    LPDEST        Where enscript sends print files.
  55. #
  56. # Revision History:
  57. #    $Log: setup,v $
  58. # Revision 1.32  1994/02/22  21:53:27  carlson
  59. # Added checking of flag to know when we are in an Emacs subshell.
  60. # Added check to see if we are actually a terminal session or just a subshell.
  61. # Always define WINEDITOR.
  62. # Changed colors of prompt.
  63. #
  64. # Revision 1.31  1993/12/16  22:53:48  carlson
  65. # Changed my home host to heaven.
  66. #
  67. # Revision 1.30  1993/12/16  14:49:22  carlson
  68. # Modified so we don't check the hostname to find out if this is a
  69. #   dialback connection.  Use the user (which should be UNKNOWN).
  70. #
  71. # Revision 1.29  93/08/18  17:12:21  carlson
  72. # Modified the terminal type to use when coming from dial-up to be vt100.
  73. # Added some documentation on how the DISPLAY variable is set.
  74. # Do the same for both calling from dialback and using a vt100.
  75. # Handle special case when logging in from an HP terminal.
  76. # Add $HOME/app-defaults to search path for X defaults.
  77. # Replace checks for $prompt with checks to my variable $ansiterm.
  78. # Added aliases for rcp and xv.
  79. # Revision 1.28  93/06/02  10:59:36  carlson
  80. # Modify to keep version in a file identified by each host.  This way,
  81. #   I can NFS mount my home directory, if I want.
  82. # Changed prompt to have the expanded hostname rather than compute it
  83. #   each time.
  84. # Modified aliases that fix the title of the window to use expanded
  85. #   hostname rather than compute it each time.
  86. # Moved all the special stuff for opening windows to .sgisession.
  87. # Revision 1.27  93/03/29  09:31:39  carlson
  88. # Only run unique on path if it exists.
  89. # Added cu alias to clean up after using.
  90. # Only run zmail if it exists.
  91. # Only run status e-lisp function if it exists.
  92. # Revision 1.19  1993/03/27  04:52:14  chris
  93. # Added alias for cu so that it fixes the title bar.
  94. # Added neatsy keansy stuff for epoch when it first loads.
  95. #
  96. # Revision 1.18  1993/02/15  01:05:00  chris
  97. # Modified to be more machine independent.
  98. # Modified mailbox to better know where we are.
  99. #
  100. # Revision 1.25  93/01/22  12:27:01  carlson
  101. # Modified check for LPDEST to make sure we are running on an IRIX
  102. #   system first.
  103. # Modified calls to run mailbox to have better Lat/Long values and to
  104. #   run the mail programs under xwsh.
  105. # Revision 1.24  93/01/06  17:42:30  carlson
  106. # Modified EMACSLOADPATH to use the new format.
  107. # Revision 1.23  92/10/29  13:30:12  carlson
  108. # Added backup (bu) alias.
  109. # Revision 1.22  92/10/27  10:10:44  carlson
  110. # Do not make anything dependent on $OS being defined.
  111. # Use 'unique' program to remove duplicate entries in path variable.
  112. # Added xlock alias.
  113. # Make sure labugs user exists before creating the mailbox for them.
  114. # Disable bell from mailbox program (since zmail does it for me).
  115. # Revision 1.21  92/10/07  14:39:18  carlson
  116. # No longer check if OS is defined for a number of things.  It didn't
  117. #   work as expected.
  118. # Move the definition of OS to the end of the common script.
  119. # Use command unique instead of using a script to remove duplicate
  120. #   directories from the path statement.
  121. # Change where zmail is positioned.
  122. # Remove position information from calls to epoch.
  123. # Revision 1.20  92/08/28  17:13:26  carlson
  124. # Use the variable OS to determine if we need to do things.  This way we
  125. #   don't duplicate efforts.
  126. # Found a faster way to clear away duplicate entries in path.
  127. # Remove alias for make to pmake.
  128. # Define aliases for seticon and settitle in appropriate place.
  129. # Remove size info for epoch.
  130. # Revision 1.19  92/08/28  11:18:31  carlson
  131. # Fixed EXPLORERHOME to be /usr relative.
  132. # Changed default mail handler for mailbox back to BSD mail.
  133. # Automatically load zmail.
  134. # Don't include size information when loading epoch.
  135. # Revision 1.18  92/08/21  15:30:01  carlson
  136. # Added environment variable XENVIRONMENT if .Xdefaults_xxx is defined.
  137. # Revision 1.17  92/08/21  12:57:09  carlson
  138. # Skip a whole bunch of stuff if ENVONLY is defined.  This makes the program
  139. #   userenv (which is called in .xsession) work.
  140. # Change EXPLORERHOME to be /usr relative instead of in /d1.
  141. # Revision 1.16  92/08/19  16:42:42  carlson
  142. # Fixed path to find things in /usr rather than on /d1.
  143. # Added wp to path.
  144. # Revision 1.15  92/08/11  16:48:43  carlson
  145. # If remote host is dialback, then assume iris-ansi-net terminal device.
  146. # Create the .version file if it doesn't exist or it is zero in length.  For
  147. #   some reason, there are times when it gets cleared.
  148. # If the remote host is dialback, remove the DISPLAY environment variable.
  149. #   Otherwise, set the display variable to point to the remote host.
  150. # If the DISPLAY environment variable is set, define emacs, epoch and
  151. #   zmail to use them.  Otherwise, make emacs use the terminal device and
  152. #   don't allow epoch to run.
  153. # Remove stuff that came from Jack's .cshrc a long time ago.
  154. # Revision 1.14  92/03/18  16:14:02  carlson
  155. # Unset clobber - was set by desktop group in /etc/cshrc.
  156. # Added aliases for epoch and zmail.
  157. # Removed running of emacs by default.
  158. # Changed running of mailbox to use zmail, not Mail.
  159. # If epoch exists, run epoch else run emacs on status file.
  160. # If not home machine just run epoch or emacs.
  161. # Revision 1.13  92/01/22  15:23:39  carlson
  162. # Added environment EXPLORERHOME.
  163. # Broke up search path to be divided into two.  Those that are to be
  164. #   searched first and those that are searched last.  This improves the
  165. #   way it works when changing to root.
  166. # Added Framemaker and Explorer to the search path.
  167. # Clean up search path to remove anything already there.
  168. # Revision 1.12  91/10/10  16:12:45  carlson
  169. # Modified netemacs alias to pass parameters in the right place.
  170. # Revision 1.11  91/09/06  13:34:12  carlson
  171. # Removed alias of domcs when on home machine.
  172. # Revision 1.10  91/09/06  12:33:33  carlson
  173. # Modified RCS Header symbol to Id symbol.
  174. # Added netemacs alias.
  175. # Revision 1.9  91/08/27  15:20:37  carlson
  176. # Have the status EMACS start in directory misc.  This way it will load
  177. # the .emacsrc file.
  178. # Revision 1.8  91/08/27  13:12:44  carlson
  179. # Added alias for ci.
  180. # Revision 1.7  91/08/27  12:41:17  carlson
  181. # Modified definition of OS to allow no .version file.
  182. # Include search for FrameMaker directory.
  183. # Set notify only if not console window.
  184. # Revision 1.6  91/08/13  13:10:31  carlson
  185. # Modified call to run emacs editing status to have special instance name.
  186. # Revision 1.5  91/08/13  12:00:44  carlson
  187. # Added RCS special symbols.
  188. # Improved documentation in title block.
  189. # Added emacs alias to handle new X version of emacs.
  190. # Start two emacs windows, one for standard use, one for status.
  191. #-------------------------------------------------------------------------
  192.  
  193. set home_host = heaven
  194. set hostname = `hostname`
  195.  
  196. if ( $?REMOTEHOST ) then
  197.     if ( "$REMOTEUSER" == "UNKNOWN" ) then
  198.     setenv TERM vt100
  199.     endif
  200. endif
  201.  
  202. if ( ! $?ENVONLY ) then
  203.     set ansiterm = 0
  204.     if ( $?prompt && ! $?INEMACS ) then
  205.     set ansiterm = 1
  206.     if ( -t 0 ) then
  207.         if ( "$TERM" == "iris-ansi" || "$TERM" == "iris-ansi-net" ) \
  208.         set ansiterm = 2
  209.         if ( "$TERM" == "vt100" ) set ansiterm = 3
  210.     endif
  211.     endif
  212. endif
  213.  
  214. #-----
  215. # Required by X Windows
  216. #
  217. # Set the DISPLAY environment variable.
  218. #    1. If remote host is dialback, then we are logging in from home
  219. #       and we aren't using X.  Remove the DISPLAY environment variable.
  220. #    2. If there is no prompt, then we are using 'rcp' and we don't
  221. #       need to worry about a DISPLAY environment variable.
  222. #    3. If the 'hosts' file lists only the IP address and the hostname,
  223. #       then we must be at PDA and need to use the IP address instead
  224. #       of the hostname provided.
  225. #    4. Set XUSERFILESEARCHPATH so that app-defaults files will be used
  226. #       properly.
  227. #    5. If we are not logging in remotely, just set DISPLAY to the
  228. #       local screen.
  229. #
  230. if ( $?REMOTEHOST ) then
  231.     if ( "$REMOTEUSER" == "UNKNOWN" || $ansiterm != 2 ) then
  232.     if ( $?DISPLAY ) unsetenv DISPLAY
  233.     else if ( $ansiterm > 0 ) then
  234.     set ip = `ypmatch $REMOTEHOST hosts`
  235.     if ( $#ip == 2 ) then
  236.         setenv DISPLAY $ip[1]\:0
  237.     else
  238.         setenv DISPLAY $REMOTEHOST\:0
  239.     endif
  240.     unset ip
  241.     setenv XUSERFILESEARCHPATH "$HOME/app-defaults/%N:`/usr/bin/X11/appdefpath`"
  242.     endif
  243. else
  244.     setenv DISPLAY :0
  245. endif
  246.  
  247. #-----
  248. # Set other environment variables.
  249. #
  250. if ( ! $?EMACSLOADPATH ) setenv EMACSLOADPATH    ~/emacs:
  251. if ( ! $?ENVONLY ) then
  252.     setenv WINEDITOR        /usr/local/bin/emacs
  253.     if ( ! $?CONSOLE ) \
  254.     setenv CONSOLE        false
  255.     set x = `uname`
  256.     if ( "$x" == "IRIX" ) then
  257.     if ( ! $?LPDEST ) then
  258.         set x = ( `lpstat -d` )
  259.         if ( "$x[1]" != "no" ) setenv LPDEST    $x[4]
  260.     endif
  261.     endif
  262.     unset x
  263.     if ( ! $?EXPLORERHOME && -e /usr/explorer/bin ) \
  264.     setenv EXPLORERHOME    /usr/explorer
  265. endif
  266.  
  267. if ( $?XSCREEN ) then
  268.     if ( "$XSCREEN" == "1280x1024" && -r $HOME/.Xdefaults_1280 ) then
  269.     setenv XENVIRONMENT $HOME/.Xdefaults_1280
  270.     else if ( "$XSCREEN" == "1024x768" && -r $HOME/.Xdefaults_1024 ) then
  271.     setenv XENVIRONMENT $HOME/.Xdefaults_1024
  272.     endif
  273. endif
  274.  
  275. #-----
  276. # Set the search path.
  277. #
  278. # dir1    Directories to search first.
  279. # dir2    Directories to search last.
  280. #
  281. set dir1
  282. if ( -e ~/bin )        set dir1 = ( $dir1 ~/bin )
  283. if ( -e ~/scripts )        set dir1 = ( $dir1 ~/scripts )
  284. if ( -e /usr/local/bin )    set dir1 = ( $dir1 /usr/local/bin )
  285.  
  286. set dir2
  287. if ( -e /usr/frame/bin )    set dir2 = ( $dir2 /usr/frame/bin )
  288. if ( -e /usr/explorer/bin )    set dir2 = ( $dir2 /usr/explorer/bin )
  289. if ( -e /usr/wp/bin )    set dir2 = ( $dir2 /usr/wp/bin /usr/wp/sbin )
  290.  
  291. if ( -o /bin/su ) then
  292.     set path = ( $path $dir1 $dir2 )
  293. else
  294.     set path = ( . $dir1 $path $dir2 )
  295. endif
  296.  
  297. if ( -e ~/bin/unique ) set path = ( `unique $path` )
  298.  
  299. unset dir1
  300. unset dir2
  301.  
  302. #-----
  303. # Make an environment variable that tells us what release of the
  304. # operating system we are running.  Note that we create a file called
  305. # .version later in the login stuff.  This is because it takes too
  306. # long to compute it here.
  307. #
  308. if ( ! $?OS ) then
  309.     set y = `uname -r`
  310.     if ( -e ~/.${hostname}_version && ! -z ~/.${hostname}_version ) then
  311.     set x = ( `cat ~/.${hostname}_version` )
  312.     setenv OS "$y-$x[3]"
  313.     unset x
  314.     else
  315.     setenv OS "$y"
  316.     endif
  317.     unset y
  318. endif
  319.  
  320. if ( $?ENVONLY ) exit
  321.  
  322. ##########################################################################
  323. # CSHRC stuff
  324. #
  325.  
  326. if ( $?cshrc ) then
  327. #----
  328. # Do pretty stuff to prompt string
  329. #   1.    Don't do this if we are not running with an ANSI terminal.
  330. #   2.    If we are the owner of /bin/su, then we must be running in
  331. #    superuser mode and we'll reverse video the prompt.  Otherwise,
  332. #    we'll just use the highlight color.
  333. #
  334.     if ( $ansiterm > 0 ) then
  335.     if ( $ansiterm > 1 ) then
  336.         if ( -o /bin/su ) then
  337.         set prompt="${hostname}:$user [\!] > "
  338.         else
  339.         set prompt="${hostname}:$user [\!] > "
  340.         endif
  341.     else
  342.         set prompt="${hostname}:$user [\!]$prompt "
  343.     endif
  344.     endif
  345.  
  346. #----
  347. # Set csh variables here.  These variables must be set for each shell
  348. # invokation.
  349. #
  350.     set    history    = 100
  351.     set x
  352.     if ( -e ~/developer )    set x = ($x ~/developer)
  353.     if ( -e /usr/local/emacs )    set x = ($x /usr/local/emacs)
  354.     set    cdpath    = (~ $x)
  355.     unset x
  356.     set    filec
  357.     set    fignore    = (.o .a .out \~)
  358.     unset autologout
  359.     set    ignoreeof
  360.     if ( "$CONSOLE" != "true" ) set notify
  361.     unset noclobber
  362.  
  363. #----
  364. # Perform alias definitions.  These must be set for each invokation of
  365. # the csh.
  366. #
  367. # list directories in columns
  368. #
  369.     alias ls    'ls -FC'
  370.     alias ll    'ls -alF \!* | more'
  371.     alias lt    'ls -alFt \!* | more'
  372.     alias mail    Mail -n
  373.     if ( $?DISPLAY ) then
  374.     alias emacs    '/usr/local/bin/emacs \!* &'
  375.     alias epoch    '/usr/local/bin/epoch \!* &'
  376.     alias zmail    'zmail -gui \!* &'
  377.     alias xlock    'xlock -mode random +nolock'
  378.     else
  379.     alias emacs    'emacs -nw'
  380.     alias epoch    'echo "epoch will not run over a modem"'
  381.     endif
  382.     if ( -e ~/scripts ) then
  383.     alias co    '~/scripts/co-script \!*'
  384.     alias col    '~/scripts/col-script -i \!*'
  385.     alias ci    '~/scripts/ci-script \!*'
  386.     endif
  387.     alias unlock "rcs -u \!* ; rm -f \!* >&/dev/null"
  388.  
  389. #----
  390. # Define aliases to do fancy things to the title bar.
  391. #
  392.     if ( $ansiterm == 2 ) then
  393.     alias seticon    'echo "\033P3.y\!*\033\\\c"'
  394.     alias settitle    'echo "\033P1.y\!*\033\\\c"'
  395.  
  396.     if ( "$CONSOLE" == "true" ) then
  397.         alias cu    'cu \!* ; echo "\033P1.yConsole:${cwd}\033\\\c"'
  398.         alias cd    'cd \!* ; echo "\033P1.yConsole:${cwd}\033\\\c"'
  399.         alias rlogin 'rlogin \!* ; echo "\033P1.yConsole:${cwd}\033\\\c"'
  400.         alias rsh    'rsh \!* ; echo "\033P1.yConsole:${cwd}\033\\\c"'
  401.         alias pushd    'pushd \!* ; echo "\033P1.yConsole:${cwd}\033\\\c"'
  402.         alias popd    'popd \!* ; echo "\033P1.yConsole:${cwd}\033\\\c"'
  403.     else
  404.         alias cu    'cu \!* ; echo "\033P1.y${hostname}:${cwd}\033\\\c"'
  405.         alias cd    'cd \!* ; echo "\033P1.y${hostname}:${cwd}\033\\\c"'
  406.         alias rlogin 'rlogin \!* ; echo "\033P1.y${hostname}:${cwd}\033\\\c"'
  407.         alias rsh    'rsh \!* ; echo "\033P1.y${hostname}:${cwd}\033\\\c"'
  408.         alias pushd    'pushd \!* ; echo "\033P1.y${hostname}:${cwd}\033\\\c"'
  409.         alias popd    'popd \!* ; echo "\033P1.y${hostname}:${cwd}\033\\\c"'
  410.     endif
  411.     endif
  412.  
  413.     alias etags        etags -t
  414.     alias snoop        '/usr/demos/bin/snoop'
  415.     if ( "${hostname}" == "$home_host" ) then
  416.     alias xrn    'xrn-motif &'
  417.     endif
  418.     alias chkalias    'rsh relay.sgi.com -l guest ypmatch -k \!* aliases'
  419.     alias grepalias    '(rsh relay.sgi.com -l guest ypcat -k aliases) | grep "\!*"'
  420.     alias ping        /usr/etc/ping
  421.     alias bu        'cd $cwd:h'
  422.     alias rcp        'rcp -rv'
  423.     alias xv        'xv -8'
  424.  
  425. endif
  426.  
  427. ##########################################################################
  428. # LOGIN stuff
  429. #
  430.  
  431. if ( $?login ) then
  432. #-----
  433. # Do pretty stuff to window border
  434. #
  435.     if ( "$CONSOLE" == "true" ) then
  436.     echo "\033P1.yConsole at ${hostname}, user: $user\033\\\c"
  437.     else
  438.     if ( $ansiterm == 2 ) then
  439.         if ( $?REMOTEHOST ) then
  440.         echo "\033P1.y${hostname}:`pwd`\033\\\c"
  441.         echo "\033P3.y${hostname}\033\\\c"
  442.         else
  443.         echo "\033P1.y`pwd`\033\\\c"
  444.         echo "\033P3.y${user}\033\\\c"
  445.         endif
  446.     endif
  447.     endif
  448.  
  449. #-----
  450. # Disable functions for f3 and f4 keys.  See bindkey(1).
  451. #
  452.     if ( $ansiterm == 2 ) then
  453.     bindkey -l f3
  454.     bindkey -l f4
  455.     endif
  456.  
  457. endif
  458.  
  459. unset ansiterm
  460. unset home_host
  461.  
  462. ### Local Variables:
  463. ### auto-fill-hook: nil
  464. ### End:
  465.